/**
 * Created by claim on 17-3-19.
 */
const Koa = require('koa');
const app = new Koa();

const router = require('./router');

app.use(async(ctx, next) => {
    const start = new Date();
    // ctx.custom_name = 'a';
    await next();
    const ms = new Date() - start;
    console.log(`${ctx.method} ${ctx.url} - ${ms}`);
});

app
    .use(router.routes())
    .use(router.allowedMethods());

app.use(ctx => {
    console.log("Request return");
    // console.log(ctx.custom_name);
});

app.listen(3000);